package com.zzx.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zzx.mapper.DeptMapper;
import com.zzx.mapper.EmployeeMapper;
import com.zzx.model.Employee;
import com.zzx.service.EmployeeService;

@RestController
@RequestMapping("employee")
public class EmployeeController {

	@Resource
	private EmployeeService employeeService;
	
	private EmployeeMapper employeeMapper;
//	
//	@GetMapping("byId")
//	@ResponseBody
//	public Object findById(int id) {
//		return employeeMapper.findById(id);
//	}
	
	@GetMapping("all")
	@ResponseBody
	public List<Employee> findAll() {
		try {
			return employeeService.findAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	@GetMapping("all_two")
	public Object findTwo() {
		try {
			return employeeMapper.findAllTwo();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	@Resource
	private DeptMapper deptMapper;
	
	@GetMapping("dept")
	public @ResponseBody Object findDept(Integer deptId) {
			return deptMapper.findById(deptId);
		
	}
}
